/**
 * @author lu
 * @date 2018/8/17 15:57
 */
Game.init();
var startButton = document.getElementsByClassName("game-start-button ")[0];
startButton.onclick = function (e) {
    startButton.style.display = "none";
    startGame();
}
var startGame = function () {
    Game.run();
}

Game.canvas.addEventListener("click", function (e) {
    var x = e.offsetX;
    var y = e.offsetY;

    var onew = Game.width / hole.column;
    var oneh = Game.height / hole.row;

    var xIndex = (x / onew) >>> 0;
    var yIndex = (y / oneh) >>> 0;

    var hamsterL = xIndex * onew + (onew - 30) / 2;
    var hamsterR = hamsterL + 30;
    var hamsterT = yIndex * oneh + (oneh - 30) / 2;
    var hamsterB = hamsterT + 30;

    console.log(hamsterL, hamsterR, hamsterT, hamsterB);
    if (x > hamsterL && x < hamsterR && y > hamsterT && y < hamsterB) {
        // console.log(xIndex, yIndex);
        var hi = yIndex * hole.row + xIndex;
        Game.hamsters[hi].recoverItem("kill");

    }
});